#include <iostream>
using namespace std;

int CheckBigger(int a, int b) {return a>b;}
int CheckSmaller(int a, int b) {return a<b;}
void sort(int *arr, int count, int (*order) (int, int))
{
	while (count > 0)
	{
		for (int i = 0; i < count - 1; ++i)
		{
			if (order(arr[i], arr[i+1]))
			{
				int tmp = arr[i];	
				arr[i] = arr[i+1];
				arr[i+1] = tmp;
			}
		}
		count--;
	}
}

void display(int* arr, int count)
{
	for (int i = 0; i < count; ++i)
		cout << arr[i] << ";";
	cout << endl;
}

void main()
{
	int a[] = {9, 2, 7, 1, 8};
	sort(a, 5, CheckBigger);
	display(a, 5);
	sort(a, 5, CheckSmaller);
	display(a, 5);
}